package com.sbtr.business.equip.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.equip.dto.EquipEntityDto;
import com.sbtr.business.equip.entity.EquipEntity;
import com.sbtr.business.equip.mapper.EquipEntityMapper;
import com.sbtr.business.equip.service.EquipEntityService;
import com.sbtr.common.PageDto;
import com.sbtr.util.PageDtoUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 设备实例信息字段列表 Service接口实现类
 *
 * @author dgl
 * @since  2023-03-14
 */
@Transactional
@Service
public class EquipEntityServiceImpl extends ServiceImpl<EquipEntityMapper,EquipEntity> implements EquipEntityService {

    @Autowired
    EquipEntityMapper equipEntityMapper;

    @Override
    public PageDto<EquipEntity> pageList(EquipEntityDto equipEntityDto) {

        IPage<EquipEntity> page = new Page<>();
        page.setSize(equipEntityDto.getPageSize());
        page.setCurrent(equipEntityDto.getPage());
        page = equipEntityMapper.selectPages(page, BeanUtil.beanToMap(equipEntityDto));
        PageDto<EquipEntity> r = PageDtoUtils.getPageDtoByIPage(page, EquipEntity.class);

        return r;
    }
}

